package com.ruoyi.ai.service.impl.translation;

import com.ruoyi.ai.service.url.DomainService;
import com.ruoyi.common.annotation.TranslationType;
import com.ruoyi.common.constant.TransConstant;
import com.ruoyi.common.translation.TranslationInterface;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Objects;

/**
 * 会员等级名称翻译实现
 */
@Component
@AllArgsConstructor
@TranslationType(type = TransConstant.REPLACE_DOMAIN_URL)
public class ReplaceDomainUrlTranslationImpl implements TranslationInterface<String> {

    private final DomainService domainService;

    @Override
    public String translation(Object key, String other) {
        if(Objects.isNull(key)){
            return null;
        }
        return domainService.replaceCurrentDomainName(key.toString(),other);
    }
}
